package htw.list;

// Programmiersprachen 1 (Java)
// Prof. Dr. H. G. Folz
// 2000
//
 
import de.htw.saarland.stl.Stdin;

/** Testprogramm fuer String-Stack */
public class StringStackTest {
    private final int POP   = 1;
    private final int PUSH  = 2;
    private final int EMPTY = 3;
    private final int FULL  = 4;
    private final int SIZE  = 5;
    private final int KONSTRUKTOR = 6;
    private final int ENDE  = 9;

    public StringStackTest() {
        StringStack s1 = new StringStack();
        String wert;
        int groesse;
        int auswahl = 0;
        do {
            try {
		System.out.println("s1: " + s1);
		auswahl = auswaehlen();
		switch (auswahl) {
		case POP  : System.out.println("pop: " + s1.top());
			    s1.pop();
			    break;
		case PUSH : wert = Stdin.readlnString("Wert: ");
			    s1.push(wert);
			    break;
		case EMPTY: System.out.println("empty: " + s1.empty());
			    break;
		case FULL : System.out.println("full: " + s1.full());
			    break;
		case SIZE : System.out.println("size: " + s1.size());
			    break;
		case KONSTRUKTOR:
			    s1 = new StringStack();
			    break;
		case ENDE : break;
		default   : System.out.println("Falsche Auswahl!");
		}
	    } catch (AssertionError e) {
	        System.out.println(e);
	    } catch (Exception e) {
	        System.out.println(e);
	       }
        } while (auswahl != ENDE);
   }

   public int auswaehlen() {
       System.out.println(POP   + ": pop / "
                        + PUSH  + ": push / "
                        + EMPTY + ": empty / "
                        + FULL  + ": full / "
                        + SIZE  + ": size / "
                        + KONSTRUKTOR + ": Konstruktor / "
                        + ENDE  + ": beenden ->");
       return Stdin.readlnInt();
   }

    public static void main(String[] args) {
        StringStackTest t = new StringStackTest();
    }
}

